<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    .container{
        display:flex;
    }
    </style>
</head>
<body>



<div class="container">
<?php
echo "验证码: ";
$codeTemplate = "0-1-2-3-4-5-6-7-8-9-a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z";
$arr = explode("-", $codeTemplate);
$indexArr = array_rand($arr, 4);//随机产生四个随机数存入数组中
$code = "";
foreach ($indexArr as $index) {
    // echo  $arr[$index];
    $r=mt_rand(0,255);
    $g=mt_rand(0,255);
    $b=mt_rand(0,255);

?>

    <div style="color:rgb(<?=$r?>,<?=$g?>,<?=$b?>)"><?=$arr[$index]?></div>
<?php
}
?>
</div>
</body>
</html>